<?php

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

/**
 * Class SchoolPermissionSeeder
 */
class SchoolPermissionSeeder extends Seeder
{

    public function run()
    {
        $tableNames = config('permission.table_names');
        $date = date('Y-m-d H:i:s');
        $data = [
            [
                'name' => 'roles.index',
                'description' => '角色列表',
                'group' => '权限组',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'roles.store',
                'description' => '新增角色',
                'group' => '权限组',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'roles.update',
                'description' => '编辑角色',
                'group' => '权限组',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'roles.destroy',
                'description' => '删除角色',
                'group' => '权限组',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'school-admins.index',
                'description' => '管理员列表',
                'group' => '管理员',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'school-admins.store',
                'description' => '新增管理员',
                'group' => '管理员',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'school-admins.update',
                'description' => '编辑管理员',
                'group' => '管理员',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'school-admins.refreshPassword',
                'description' => '重置管理员密码',
                'group' => '管理员',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'school-rules.update',
                'description' => '编辑学校规则',
                'group' => '学校设置',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'school-rules.index',
                'description' => '展示学校规则',
                'group' => '学校设置',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'schools.index',
                'description' => '展示学校信息',
                'group' => '学校设置',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'schools.update',
                'description' => '修改学校信息',
                'group' => '学校设置',
                'menu' => '系统管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'users.index',
                'description' => '用户列表',
                'group' => '用户列表',
                'menu' => '用户管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'users.store',
                'description' => '新增用户',
                'group' => '用户列表',
                'menu' => '用户管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'import-users.store',
                'description' => '导入用户',
                'group' => '用户列表',
                'menu' => '用户管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'users.update',
                'description' => '编辑用户',
                'group' => '用户列表',
                'menu' => '用户管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'users.destroy',
                'description' => '启用/禁用用户',
                'group' => '用户列表',
                'menu' => '用户管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'user-roles.index',
                'description' => '用户角色列表',
                'group' => '用户角色',
                'menu' => '用户管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'user-roles.store',
                'description' => '新增用户角色',
                'group' => '用户角色',
                'menu' => '用户管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'user-roles.update',
                'description' => '编辑用户角色',
                'group' => '用户角色',
                'menu' => '用户管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name' => 'user-roles.destroy',
                'description' => '更改用户默认角色',
                'group' => '用户角色',
                'menu' => '用户管理',
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'name'=> 'school-admin-logs.index',
                'description'=>'操作日志列表',
                'group'=>'操作日志',
                'menu' => '系统管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'foods.index',
                'description'=>'菜品列表',
                'group'=>'菜品',
                'menu' => '菜品管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'foods.store',
                'description'=>'新增菜品',
                'group'=>'菜品',
                'menu' => '菜品管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'foods.update',
                'description'=>'编辑菜品',
                'group'=>'菜品',
                'menu' => '菜品管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'food-types.index',
                'description'=>'菜品种类列表',
                'group'=>'菜品种类',
                'menu' => '菜品管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'food-types.store',
                'description'=>'新增菜品种类',
                'group'=>'菜品种类',
                'menu' => '菜品管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'food-types.update',
                'description'=>'编辑菜品种类',
                'group'=>'菜品种类',
                'menu' => '菜品管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'book-rules.index',
                'description'=>'订餐规则列表',
                'group'=>'订餐规则',
                'menu' => '订餐规则',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'book-rules.store',
                'description'=>'新增订餐规则',
                'group'=>'订餐规则',
                'menu' => '订餐规则',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'book-rules.update',
                'description'=>'编辑订餐规则',
                'group'=>'订餐规则',
                'menu' => '订餐规则',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'book-rules.settle',
                'description'=>'结算订餐规则',
                'group'=>'订餐规则',
                'menu' => '订餐规则',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'book-rules.destroy',
                'description'=>'取消订餐规则',
                'group'=>'订餐规则',
                'menu' => '订餐规则',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'price-categories.index',
                'description'=>'计费条目列表',
                'group'=>'计费条目',
                'menu' => '订餐规则',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'price-categories.store',
                'description'=>'新增计费条目',
                'group'=>'计费条目',
                'menu' => '订餐规则',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'price-categories.update',
                'description'=>'编辑计费条目',
                'group'=>'计费条目',
                'menu' => '订餐规则',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'book-rule-prices.store',
                'description'=>'新增订餐价格规则',
                'group'=>'订餐规则',
                'menu' => '订餐规则',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'book-rule-prices.update',
                'description'=>'编辑订餐价格规则',
                'group'=>'订餐规则',
                'menu' => '订餐规则',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'book-rule-prices.destroy',
                'description'=>'删除订餐价格规则',
                'group'=>'订餐规则',
                'menu' => '订餐规则',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'book-orders.index',
                'description'=>'订单列表',
                'group'=>'订单列表',
                'menu' => '订单管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'book-orders.update',
                'description'=>'编辑订单',
                'group'=>'订单列表',
                'menu' => '订单管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'order-statistics.index',
                'description'=>'订单统计',
                'group'=>'订单统计',
                'menu' => '订单管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'meal-statistics.index',
                'description'=>'用餐统计',
                'group'=>'用餐统计',
                'menu' => '订单管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'order-reviews.index',
                'description'=>'订单审核列表',
                'group'=>'订单审核',
                'menu' => '订单管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
            [
                'name'=> 'order-reviews.update',
                'description'=>'审核订单',
                'group'=>'订单审核',
                'menu' => '订单管理',
                'created_at'=>$date,
                'updated_at'=>$date
            ],
        ];
        foreach ($data as $value) {
            if (!DB::table($tableNames['permissions'])->where([
                ['name', $value['name']],
                ['guard_name', "school"]
            ])->exists()) {
                $value['guard_name'] = "school";
                DB::table($tableNames['permissions'])->insert($value);
            }
        }
    }
}
